package com.easy.project.controller.system;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.easy.project.base.result.BizResult;
import com.easy.project.domain.dto.system.RoleDTO;
import com.easy.project.domain.dto.system.RoleEditDTO;
import com.easy.project.domain.dto.system.UserEditDTO;
import com.easy.project.domain.vo.system.SysRoleVO;
import com.easy.project.service.system.ISysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 系统角色表 前端控制器
 * </p>
 *
 * @author wxz
 * @since 2024-01-10
 */
@RestController
@RequestMapping("/sys-role-po")
@Api(tags = "系统管理-角色管理")
public class SysRoleController {

    @Resource
    private ISysRoleService sysRoleService;

    @GetMapping("/role/page")
    @ApiOperation(value = "角色列表分页")
    public BizResult<IPage<SysRoleVO>> rolePage(RoleDTO roleDTO) {
        return BizResult.success(sysRoleService.rolePage(roleDTO));
    }

    @GetMapping("/all/role")
    @ApiOperation(value = "全部角色")
    public BizResult<List<SysRoleVO>> allRole() {
        return BizResult.success(sysRoleService.allRole());
    }

    @PostMapping("/role/edit")
    @ApiOperation(value = "编辑角色",notes = "编辑角色 有id更新 无id新增")
    public BizResult<Void> roleEdit(@RequestBody @Validated RoleEditDTO roleEditDTO){
        sysRoleService.roleEdit(roleEditDTO);
        return BizResult.success();
    }
}
